package sng.modules.view.components.city.state
{
	import mx.controls.Alert;
	
	import sng.modules.view.components.city.cursor.CityCursor;
	import sng.modules.view.components.city.cursor.CityCursorManager;
	import sng.modules.view.components.city.logic.City;
	import sng.modules.view.components.city.logic.unit.BaseBuilding;
	import sng.modules.view.components.city.strategy.CityStrategyManage;
	
	/**
	 * 
	 * @author leonliu
	 * 移动状态
	 * 
	 */	
	public class CityMoveState implements ICityState
	{
		public function CityMoveState(_city:City)
		{
			city=_city;
			
			//更改指针状态 eason 20110714
			CityCursorManager.getInstance().setCursor(CityCursor.MOVE_CURSOR);
		}
		
		public var city:City;
		public function Execute(parameter:*=null):void
		{
			//Alert.show(city.currentBuilding.id);
			if (city.currentBuilding.isDragStart)//建筑已经处于移动状态
			{
				if (city.currentBuilding.EndMove())
				{
					city.currentBuilding.isDragStart=false;
					CityStrategyManage.setAddBonusRate(city.currentBuilding);//增加新地址带来的增益效果影响 
					CityStrategyManage.setIdelBuilds(city.currentBuilding,false);
					//					if(city.currentBuilding.uVO.buildStep==0 || city.currentBuilding.uVO.buildStep>=city.currentBuilding.vo.createStep)
					//						city.currentBuilding.setBuildState(new BuildNormalState());					
					//					else
					//						city.currentBuilding.setBuildState(new BuildNewState());
				}
			}
			else
			{
				
				CityStrategyManage.setDelBonusRate(city.currentBuilding);//删除原地址带来的增益效果影响 
				CityStrategyManage.setIdelBuilds(city.currentBuilding,true);//只影响到路 民房和商业建筑
				
				//city.currentBuilding.setBuildState(new BuildMoveState());
				city.currentBuilding.BeginMove();
				//				build.currentState=new BuildMoveState();
				//				build.currentState.Execute(build);
			}
		}
		
		
		public function toString():String
		{
			return "CityMoveState";
		}
		
	}
}